<!--编辑运维-->
<!--编辑咨询-->
<template>
    <div>
        <el-row>
            <el-col :span="18">
                <el-form :inline="true" :model="formO" class="demo-form-inline">
                    <!--主营业务-->
                    <el-form-item label="主营业务">
                        <el-input v-model="formO.operation_main_business" placeholder="主营业务"></el-input>
                    </el-form-item>
                </el-form>
                <!--企业优势-->
                <el-form :inline="true" :model="formO" class="demo-form-inline">
                    <el-form-item label="企业优势">
                    <el-input v-model="formO.enterprise_advantage" placeholder="企业优势"></el-input>
                </el-form-item>
                </el-form>
                <!--业务区域-->
                <el-form :inline="true" :model="form" class="demo-form-inline">
                    <el-form-item label="业务区域">
                        <span v-for="item in form.provinceOptions" style="margin:10px">{{item}}</span>
                    </el-form-item>
                    <el-button type="info" @click="openDialog('addArea')" style="margin-bottom:20px">设置区域</el-button>
                </el-form>
                <!--运维补差能力-->
                <el-form :inline="true" :model="formO" class="demo-form-inline">
                    <el-form-item label="运维补差能力">
                        <el-input v-model="formO.operation_bc_ability" placeholder="运维补差能力" type="number"></el-input>
                    </el-form-item>
                    <span sty style="font-size: 25px">万元</span>
                </el-form>
                <!--添加关键人物-->
                <h3>关键人物</h3>
                <el-form :inline="true"  class="demo-form-inline" v-for="(item,index) in arr" style="padding-left: 80px">
                    <el-form-item >
                        <el-select v-model="formO.operation_relation_person[index]" placeholder="请选择">
                            <el-option
                                    v-for="data in JlMessage"
                                    :label="data.personal_name"
                                    :value="data.personal_id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="职务">
                        <el-select v-model="formO.operation_relation_position[index]" placeholder="请选择">
                            <el-option
                                    v-for="data in Duty"
                                    :key="data.id"
                                    :label="data.name"
                                    :value="data.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-button type="text" @click="delMan(index)">移除</el-button>
                </el-form>
                <el-button type="info" @click="addMan" style="margin-left: 80px">添加人物</el-button>
            </el-col>
            <el-col :span="1">
                <hr style="height:200px;width: 1px">
            </el-col>
            <el-col :span="5"><div >
                <h2>评价星级</h2>
                <el-form :inline="true" :model="formO" class="demo-form-inline">
                    <el-form-item>
                        <el-select v-model="formO.operation_evaluate_star" placeholder="评价星级">
                            <el-option label="一星" value="一星"></el-option>
                            <el-option label="二星" value="二星"></el-option>
                            <el-option label="三星" value="三星"></el-option>
                            <el-option label="四星" value="四星"></el-option>
                            <el-option label="五星" value="五星"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div></el-col>
        </el-row>
        <!--省份选项-->
        <el-dialog title="业务区域" :visible.sync="dialog.addArea.open" v-if="dialog.addArea.open" :modal="false" top="65%" size="small">
            <template>
                <el-checkbox-group v-model="formO.business_region">

                    <el-checkbox :label="item.district_id" v-for="item in quyuBox" style="margin: 10px">{{item.district}}</el-checkbox>
                </el-checkbox-group>
                <el-button type="primary" size="small" @click=" addProvince('addArea')">确定</el-button>
            </template>
        </el-dialog>
        <div style="width:100px;margin-left:80%">
            <el-button type="warning" @click="sendFormD">保存能力</el-button>
        </div>
    </div>
</template>
<script>
    import Bus from '@/config/bus.js'
    import _http from '@/components/common/http.vue'
    import _param from '@/components/common/param.vue'
    export default {
        data() {
            return {
                apiPort:{
                    DutyApi:'diction/getEnterpriseType',
                    customerManager:'ctm/v1/getPersonal',
//                    区域字典
                    quyuApi:'diction/getProince',
                },
                dialog:{
                    addShebei:{
                        open:false
                    },
                    addArea:{
                        open:false
                    }
                },
                //  关键人物信息存储
                entrepot:[{name:'',status:''}],
                keyManmessage:[{
                    man:[
                        {
                            value: '选项4',
                            label: '人物一'
                        }, {
                            value: '选项5',
                            label: '人物二'
                        }
                    ],
                    duty:[
                        {
                            value: '选项4',
                            label: '人物三'
                        },
                        {
                            value: '选项5',
                            label: '人物四'
                        }
                    ]}
                ],
                information:{
                    classes:'综合',
                    issued:'住建部',
                    grade:'甲级',
                    charge:'100000元每案',
                    professField:'土地规划，环保设计',
                    keyMan1:'俞兆洪-总裁/CEO-18058715658',
                    keyMan2:'吴高翔-销售-18058715658'
                },
                formO:{
                    operation_main_business:'',
                    enterprise_advantage:'',
                    operation_bc_ability:'',
                    business_region:[],
                    operation_evaluate_star:"",
                    operation_relation_person:[],
                    operation_relation_position:[],
                },
                form:{
                    provinceOptions:[],
                    provinceList:[],
                },
                quyuBox:'',
                JlMessage:'',
                Duty:'',
                arr:[],
                userid:''
            }
        },
        mounted(){
            this.userid = localStorage.getItem('userId')
            this.getDicdata()
        },
        methods:{
            //            传递参数的方法
            sendFormD(){
                var that = this
                if(this.formO.operation_relation_position.length==this.formO.operation_relation_person.length){
                    setTimeout(function(){
                        Bus.$emit("submitFormO",that.formO)
                        that.$message({
                            message: '保存成功',
                            type: 'success'
                        });
                    },200)}
                else{
                        that.$message({
                            message: '补全关系人物',
                            type: 'warning'
                        });
                    }
                },
            getDicdata(){
                var that = this
                var paramsComZ = that.querystring.stringify({userid:that.userid})
                _http.axiosRequest(that,that.apiPort.quyuApi,paramsComZ,(res)=>{
                    console.log("quyu")
                console.log(res.data.data)
                that.quyuBox=res.data.data
            })
                var paramsComZ = that.querystring.stringify({userid:that.userid})
                _http.axiosRequest(that,that.apiPort.customerManager,paramsComZ,(res)=>{
                    that.JlMessage=res.data
                console.log('客户经理')
                console.log(that.JlMessage)
            })
                var paramComZ={code:"zhiwei",userid:that.userid}
                var paramsComZ = that.querystring.stringify(paramComZ)
                _http.axiosRequest(that,that.apiPort.DutyApi,paramsComZ,(res)=>{
                    that.Duty=res.data.data
            })
            },
            addProvince(addField){
                this.form.provinceOptions=[]
                var fie = this.quyuBox
                var che = this.formO.business_region
                for(var i in che){
                    for(var j in fie){
                        if(fie[j].district_id==che[i]){
                            this.form.provinceOptions.push(fie[j].district)
                        }
                    }
                }
                this.dialog[addField].open = false
            },
            openDialog(dialog){
                this.dialog[dialog].open = true
            },
            addMan(){
                this.arr.push(1)

            },
            delMan(index){
                this.arr.splice(index,1)
                this.formO.operation_relation_person.splice(index,1)
                this.formO.operation_relation_position.splice(index,1)
            },
            openDialog(dialog){
                this.dialog[dialog].open = true
            }
        }
    }
</script>